﻿using Furion.DynamicApiController;
using IndoorPosition.Server.Core.Utils;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IndoorPosition.Server.Application
{
    /// <summary>
    /// 建筑相关服务接口
    /// </summary>
    public class BuildingAppService : IDynamicApiController
    {
        IBuildingService _buildingService;

        public BuildingAppService(IBuildingService buildingService)
        {
            _buildingService = buildingService;
        }

        /// <summary>
        /// 添加建筑
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<int> Add([FromForm]BuildingInputDto input)
        {
            return await _buildingService.AddAsync(input);
        }

        /// <summary>
        /// 删除建筑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task Delete(int id)
        {
            await _buildingService.DeleteAsync(id);
        }

        /// <summary>
        /// 根据ID获取建筑物信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<BuildingDto> Get(int id)
        {
            return await _buildingService.GetAsync(id);
        }

        /// <summary>
        /// 分页获建筑信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedList<BuildingDto>> List(PageInputDto input)
        {
            return await _buildingService.ListAsync(input);
        }

        /// <summary>
        /// 下载模型文件
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> DownloadModel(string fileName)
        {
            return await _buildingService.DownloadModelAsync(fileName);
        }
    }
}
